import axios, {type AxiosResponse} from "axios";
import mitt from 'mitt'

const emitter = mitt()

export const request = axios.create({
    baseURL: '/api',
})

request.interceptors.response.use(function (resp: AxiosResponse<Base<any>>) :AxiosResponse {
    if (resp.data.code !== 200) {
        emitter.emit('apiError', resp.data.msg)
    }
    return resp
})